package com.lh.lock;

import java.util.concurrent.Semaphore;

/**
 * 锁粗化
 * 假如方法中首尾相接，前后相邻的都是同一把锁对象，那JIT编译器就会把这几个synchronized块并成一个大块
 * 加粗加大了范围，避免了此次去申请和释放锁，提高了性能
 */
public class LockBigTest {

    public static void main(String[] args) {


        Object lock = new Object();

        new Thread(()->{
            synchronized (lock){
                System.out.println("-------1");
            }
            synchronized (lock){
                System.out.println("-------2");
            }
            synchronized (lock){
                System.out.println("-------3");
            }
        }).start();

    }
}
